<template>
  <div>
    <van-search autofocus v-model="kw" placeholder="请输入搜索关键词" />
      <show-list :arr="arr"></show-list>
  </div>
</template>

<script>
import {reqsearch} from "../../http/http"
export default {
  data(){
    // 关键词
    return{
      kw:"",
      // 搜索结果
      arr:[]
    }
  },
watch: {
  // 获取KW
  kw(){
   if(this.kw==""){
    this.arr=[];
    return
   }
    reqsearch({
      keywords:this.kw,
    }).then((res)=>{
      if(res.data.code==200){
        this.arr=res.data.list?res.data.list:[];
      }
    })
  }
}
}
</script>

<style>

</style>